//
//  Emoticon.swift
//  03-表情键盘
//
//  Created by 房城鸿 on 15/10/18.
//  Copyright © 2015年 房兰峰. All rights reserved.
//

import UIKit

/// 表情符号模型
class Emoticon: NSObject {
    
    ///表情文字
    var chs:String?
    
    ///表情图片
    var png:String?
    
    /// 图像的完整路径
    var imagePath:String {
        
        return (png != nil) ? NSBundle.mainBundle().bundlePath + "/Emoticons.bundle/" + png! : ""
    }

    /// 表情的 16进制码。emoji 编码
    var code:String?{
        didSet{
            //读取 16进制的数值
            let scanner = NSScanner(string: code!)
            
            var value:UInt32 = 0
            scanner.scanHexInt(&value)
            
            emoji = String(Character(UnicodeScalar(value)))
        }
    }
    
    ///  emoji 字符串 --》表情
    var emoji:String?
    
    ///  删除按钮标记
    var isRemove = false
    
    // 构造删除按钮
    init(isRemove:Bool){
        super.init()
        self.isRemove = isRemove
    }
    
    //空白按钮标记
    var isEmpty = false
    //表情的使用频率
    var times = 0
    
    //构造空白按钮
    init(isEmpty:Bool){
        super.init()
        self.isEmpty = isEmpty
    }
    
    init(dict: [String:String]){
        super.init()
        
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) { }

    
    override var description: String{
        let key = ["chs","png","code","isRemove","isEmpty","times"]
        return dictionaryWithValuesForKeys(key).description
    }
    
    

}
